import type {
  GetCodeData,
  GetCodeParams,
  LoginCodeParams,
  LoginData,
  LoginPasswordParams,
  Picture,
} from '@/types/common'
import { http } from '@/utils/http'

/**
 * 密码登录--请求API
 */
export const loginPasswordApi = (data: LoginPasswordParams) => {
  return http.post<LoginData>('/login/password', data)
}

/**
 * 获取手机验证码--请求API
 */
export const getCodeApi = (params: GetCodeParams) => {
  return http.get<GetCodeData>('/code', { params })
}
/**
 * 手机验证码登录--请求API
 */
export const loginByMobileApi = (data: LoginCodeParams) => {
  return http.post<LoginData>('/login', data)
}

/** 上传图片/文件--请求API */
export const uploadApi = (filePath: string) => {
  return http.upload<Picture>('/upload', { name: 'file', filePath })
}
